﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    $(function() {
        // 异步HtmlForm
        var options = {
            url: '/Calender/DoNote',
            type: 'POST',
            success: function(data) {
                if (data == "通知时间不能为空")
                    alert("通知时间不能为空");
                else if (data == "EMPTY") {
                    alert("内容不能为空")
                }
                else {
                    $("#workarea_note").html(data);
                    outstandDate();
                    get_calen_cache();
                }
            }
        };

        get_calen_cache();
        $('#frmAddNote').ajaxForm(options);
    })

    function showNote(tag) {
        var note_id = $(tag).attr("note_id");
        var check = $(tag).children(".note_msg").val();
        var note_text = $(tag).children("label").html();
        note_text = note_text.replace(/\s+/g, "");

        $("#noteid").val(note_id);
        $("#operNote").val(note_text);
        $("#textMsg").removeAttr("check");
        $("#textMsg").attr("checked", check);
    }

    function cleanUp() {
        $("#noteid").val("");
        $("#textMsg").removeAttr("checked");
        $("#textMsg").attr("check", "");
    }

</script>

<div id="NotesLand">
    <div id="AddNote" style="height:160px;">
        <%using (Html.BeginForm("DoNote", "Calender", FormMethod.Post, new { id = "frmAddNote" }))
          { %>
        <div id="divNote">
            <%=Html.Hidden("noteid")%>
            <%=Html.Hidden("date")%>
            <div style=" font-size:15px; line-height:15px; padding-top:20px; height:150px;">
                <div style=" float:left; width:160px; padding-left:20px;">
                    <span style=" float:left; margin-right:15px;">日期:</span><span style=" float:left;"><label id="lblDate"><%=ViewData["date"] %></label></span>
                    <br />
                    <div style=" padding:15px 0 0 0;">
                        <%=Html.DropDownList("slcthour")%>时
                        <%=Html.DropDownList("slctminu") %>分
                    </div>
                    <br />
                    <span style=" float:left; margin-right:14px;"><%=Html.CheckBox("noteType",false) %>加急</span>
                    <span style=" float:left;"><%=Html.CheckBox("textMsg", false)%>短信提示</span>
                    <br />
                    <div style=" margin-top:15px;"><span style=" float:left; margin-right:16px;"><input type="submit" value="确定" /></span>
                    <span style=" float:left;"><input type="reset" value="新建" onclick="return cleanUp();" /></span> </div>
                </div>
                <div style=" float:left; margin-left:10px; width:550px;">
                    <%=Html.TextArea("operNote", new { style = "width:650px;height:113px;border:solid 1px #6C92AD;" })%>
                </div>
            </div>
        </div>
        <%} %>
    </div>
    <div id="NoteList" style="min-height: 150px; padding:0 20px 0 20px;;">
        <table>
            <tbody>
                <tr>
                    <th class="note_text">
                        内容
                    </th>
                    <th class="note_time">
                        时间
                    </th>
                    <th class="msg_time">
                        通知时间
                    </th>
                    <th class="note_msg">
                        短信通知
                    </th>
                    <th class="note_type">
                        加急
                    </th>
                    <th class="note_oper">
                    </th>
                </tr>
                <%var notes = ViewData["notes"] as String[][]; %>
                <%if (notes != null)
                  { %>
                <%var rowCount = notes.GetLength(0); %>
                <%for (Int32 rowIndex = 0; rowIndex < rowCount; rowIndex++)
                  { %>
                <tr>
                    <td class="note_text" note_id="<%=notes[rowIndex][0] %>" onclick="showNote(this);">
                        <label>
                            <%=notes[rowIndex][1] %></label>
                        <input type="hidden" class="note_msg" value="<%=notes[rowIndex][2] %>" />
                    </td>
                    <td class="note_time">
                        <%=notes[rowIndex][3] %>
                    </td>
                    <td class="msg_time">
                        <label>
                            <%=notes[rowIndex][4] %></label>
                    </td>
                    <td class="note_msg">
                        <label>
                            <%=notes[rowIndex][2] == "True" ? "是" : "否"%></label>
                    </td>
                    <td class="note_type">
                        <label>
                            <%=notes[rowIndex][5] == "HURRY" ? "是" : "否"%></label>
                    </td>
                    <td class="note_oper">
                        <%=Ajax.ActionLink("删除", "DeleteNote", "Calender", new { date = ViewData["date"], noteid = notes[rowIndex][0].ToString() }, new AjaxOptions { UpdateTargetId = "workarea_note", OnSuccess = "outstandDate" })%>
                    </td>
                </tr>
                <%} %>
                <%} %>
            </tbody>
        </table>
        <hr />
    </div>
</div>
